package com.hiwhitley.himei.app.base;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by hiwhitley on 2016/9/22.
 */

public abstract class BaseFragment extends Fragment {

    protected abstract int getContentViewId();

    private Unbinder unbinder;
    protected Activity mActivity;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mActivity = (Activity)context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(getContentViewId(), container, false);
        unbinder = ButterKnife.bind(this, view);
        init();
        setListener();
        return view;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder = null;
    }

    protected abstract void init();

    protected abstract void setListener();
}
